package com.itcast.n1_内存调优;


import java.util.ArrayList;
import java.util.List;

/**
 * @program: jvm
 * @description: 1.6中运行
 * @author: flyduck
 * @create: 2024-10-16 16:52
 **/
public class Test12_内存遗漏问题3_jdk6字符串常量池在永久代创建大量字符串导致内存泄漏 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        while (true){
            int i = 0;
            while (true) {
                //String.valueOf(i++).intern();//1.6：不会内存溢出
                list.add(String.valueOf(i++).intern());//1.6：OutOfMemoryError: PermGen space
            }
        }
    }
}
